home *** CD-ROM | disk | FTP | other *** search
- {.HE LIB002.INC Date, Time Functions Page #}
- {.FO Last Update of LIB002.INC : 07-09-84 DJS}
- {File : LIB002.INC }
- { For : Turbo Pascal }
- { By : David J. Smith }
- {Date : 07-09-84 }
-
- type TimeString = String[8];
-
- Function time: TimeString;
-
- {This Function will return the system time as a string in the form
- HH:MM:SS. Military format. The Result is of type String[8]}
-
- type
- regpack = record
- ax,bx,cx,dx,bp,di,si,ds,es,flags: integer;
- end;
-
- var
- recpack: regpack; {assign record}
- ah,al,ch,cl,dh: byte;
- hour,min,sec: string[2];
-
- begin
- ah := $2c; {initialize correct registers}
- with recpack do
- begin
- ax := ah shl 8 + al;
- end;
- intr($21,recpack); {call interrupt}
- with recpack do
- begin
- str(cx shr 8,hour); {convert to string}
- str(cx mod 256,min); { " }
- str(dx shr 8,sec); { " }
- end;
- if length(min) < 2 then min := '0' + min;
- if length(sec) < 2 then sec := '0' + sec;
- if length(hour) < 2 then hour := '0' + hour;
- time := hour+':'+min+':'+sec
- end;
-
-
- type DateStr = string[10];
-
- function Date: DateStr;
-
- {The Date function will return a string of the type String[10] in the
- form MM-DD-YYYY.}
-
- type
- regpack = record
- ax,bx,cx,dx,bp,si,ds,es,flags: integer;
- end;
-
- var
- recpack: regpack; {record for MsDos call}
- month,day: string[2];
- year: string[4];
- dx,cx: integer;
-
- begin
- with recpack do
- begin
- ax := $2a shl 8;
- end;
- MsDos(recpack); { call function }
- with recpack do
- begin
- str(cx,year); {convert to string}
- str(dx mod 256,day); { " }
- str(dx shr 8,month); { " }
- end;
- if Length(month) < 2 then month := '0' + month;
- if Length(day) < 2 then day := '0' + day;
- date := month+'/'+day+'/'+year;
- end;